package com.int_tech.data;

import com.int_tech.utils.HttpClient;

import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by liubch on 2018/6/8.
 */
public class testMain {

    public static void main(String[] args) {


        HttpClient.httpGet("http://127.0.0.1:8080/HYJ/getData/saveSocketLog?data=xxxx");

        String s1 = "a100200029343647123334353832303138303430333037333430362e30303034302e323135393538003131362e32343336333700 04031534 282e15 742e02 7065 ae3e 06001000f800 08 1800000003 03010006ea06";

        //贞头
        String zhetou = s1.substring(0,2);

        //芯片id
        String id = s1.substring(2,26);

        //UTC时间
        String utcTime = s1.substring(26,62);

        String utcTimeNew = "";

        int m = 1;

        for(int i = 0 ;i < utcTime.length(); i++)
        {
            if(m == 5)
            {
                utcTimeNew += "-";
            }

            if(m == 7)
            {
                utcTimeNew += "-";
            }

            if(m == 9)
            {
                utcTimeNew += " ";
            }

            if(m == 11)
            {
                utcTimeNew += ":";
            }

            if(m == 13)
            {
                utcTimeNew += ":";
            }

            if(m > 14)
            {
                break;
            }

            if(i%2 == 0)
            {

            }
            else
            {
                utcTimeNew += utcTime.substring(i,i+1);

                m++;
            }
        }

        utcTimeNew = utcTimeNew.replaceAll("--","-");
        utcTimeNew = utcTimeNew.replaceAll("::",":");
        utcTimeNew = utcTimeNew.replaceAll("  "," ");




        //纬度
        String lng = s1.substring(62,82);
        String lngNew = "";

        for(int i = 0 ;i < lng.length(); i++)
        {
            if(i%2 == 0)
            {

            }
            else
            {
                lngNew += lng.substring(i,i+1);
            }
        }

        lngNew = lngNew.replace("e",".");

        //经度
        String lat = s1.substring(82,104);

        String latNew = "";

        for(int i = 0 ;i < lat.length(); i++)
        {
            if(i%2 == 0)
            {

            }
            else
            {
                latNew += lat.substring(i,i+1);
            }
        }

        latNew = latNew.replace("e",".");

        //自定义时间
        String selfTime = s1.substring(105,113);

        //纬度短
        String lng1 = s1.substring(114,120);

        //经度短
        String lat1 = s1.substring(121,127);

        //湿度
        String wendu = s1.substring(130,132) + s1.substring(128,130);

        wendu = String.valueOf((Integer.parseInt(wendu,16)*0.00268127)-46.85);

        wendu = wendu.substring(0,wendu.lastIndexOf(".")+3);


        //湿度
        String shidu = s1.substring(135,137) + s1.substring(133,135);

        shidu = String.valueOf((Integer.parseInt(shidu,16)*0.00190735)-6);

        shidu = shidu.substring(0,shidu.lastIndexOf(".")+3)+"%";


        //振动
        String x = s1.substring(140,142) + s1.substring(138,140);

        Integer x1 = Integer.parseInt(x,16);

        x = String.valueOf(x1*3.9);

//        x = x.substring(0,x.lastIndexOf(".")+3);

        String y = s1.substring(144,146) + s1.substring(142,144);

        Integer y1 = Integer.parseInt(y,16);

        y = String.valueOf(y1*3.9);

//        y = y.substring(0,y.lastIndexOf(".")+3);

        String z = s1.substring(148,150) + s1.substring(146,148);

        Integer z1 = Integer.parseInt(z,16);

        z = String.valueOf(z1*3.9);

        z = z.substring(0,z.lastIndexOf(".")+3);

        //氦压机状态
        String status = s1.substring(151,153);

        //发电机01功能码采集值
        String gongneng01 = s1.substring(154,164);

        //发电机03功能码采集值
        String gongneng03 = s1.substring(165,177);







        /*String hex = "0006";
        Integer x = Integer.parseInt(hex,16);
        System.out.println(x);*/


    }
}
